define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'vppz/family_manage/index' + location.search,
                    // add_url: 'vppz/bdhospital/add',
                    // edit_url: 'vppz/bdhospital/edit',
                    // del_url: 'vppz/bdhospital/del',
                    // multi_url: 'vppz/bdhospital/multi',
                    // import_url: 'vppz/bdhospital/import',
                    table: 'vppz_family',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url+'&ids='+Config.user_id,
                pk: 'id',
                sortName: 'weigh',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),searchable:false},
                        {field: 'name', title: '姓名', operate: 'LIKE'},
                        {field: 'age', title: '年龄', operate: 'LIKE'},
                        {field: 'height', title: '身高', operate: 'LIKE'},
                        {field: 'weight', title: '体重', operate: 'LIKE'},
                        {field: 'blood_types', title: '血型', operate: 'LIKE'},
                        {field: 'sex', title: '性别', operate: 'LIKE'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,visible: false},
                        //{field: 'admin_id', title: __('Admin_id')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
                            buttons: [{
                                    name: 'detail',
                                    title: '详情',
									text: '详情',
                                    classname: 'btn btn-xs btn-success btn-dialog',
                                    icon: 'fa fa-list',
                                    url: 'vppz/family_manage/detail',
                                }]
						}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },


        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
